
package kaizone.haining.chaobohui.json;

import org.json.JSONObject;

public class AppRecommend {

    public static final String APPRECOMMENDLIST = "appRecommendList";

    public static final String APPNAME = "appName";

    public static final String APPSTOREURL = "appStoreUrl";

    public static final String ANDROIDSTOREURL = "androidStoreUrl";

    public static final String IOSSTOREURL = "iosStoreUrl";

    public static final String WPSTOREURL = "wpStoreUrl";

    public static final String GMTCREATE = "gmtCreate";

    public static final String GMTMODIFIED = "gmtModified";

    public static final String ID = "id";

    public static final String INTRO = "intro";

    public static final String LOGOURL = "logoUrl";

    public static final String LOGOURLMODEL = "logoUrlModel";

    private String appName;

    private String appStoreUrl;

    private String androidStoreUrl;

    private String iosStoreUrl;

    private String wpStoreUrl;

    private String gmtCreate;

    private String gmtModified;

    private int id;

    private String intro;

    private String logoUrl;

    private LogoUrlModel logoUrlModel;

    public static class LogoUrlModel {
        public static final String PATH = "path";

        public static final String SUM100X000 = "sum100x000";

        public static final String URL = "url";

        public String path;

        public String sum100x000;

        public String url;

        @Override
        public String toString() {
            return "path:" + path + ",url:" + url + ",sum100x000:" + sum100x000;
        }
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getAppStoreUrl() {
        return appStoreUrl;
    }

    public void setAppStoreUrl(String appStoreUrl) {
        this.appStoreUrl = appStoreUrl;
    }

    public String getAndroidStoreUrl() {
        return androidStoreUrl;
    }

    public void setAndroidStoreUrl(String androidStoreUrl) {
        this.androidStoreUrl = androidStoreUrl;
    }

    public String getIosStoreUrl() {
        return iosStoreUrl;
    }

    public void setIosStoreUrl(String iosStoreUrl) {
        this.iosStoreUrl = iosStoreUrl;
    }

    public String getWpStoreUrl() {
        return wpStoreUrl;
    }

    public void setWpStoreUrl(String wpStoreUrl) {
        this.wpStoreUrl = wpStoreUrl;
    }

    public String getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(String gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(String gmtModified) {
        this.gmtModified = gmtModified;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getLogoUrl() {
        return logoUrl;
    }

    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }

    public LogoUrlModel getLogoUrlModel() {
        return logoUrlModel;
    }

    public void setLogoUrlModel(LogoUrlModel logoUrlModel) {
        this.logoUrlModel = logoUrlModel;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("-----------------------");
        sb.append(APPNAME).append(":").append(appName).append("\n");
        sb.append(APPSTOREURL).append(":").append(appStoreUrl).append("\n");
        sb.append(GMTCREATE).append(":").append(gmtCreate).append("\n");
        sb.append(GMTMODIFIED).append(":").append(gmtModified).append("\n");
        sb.append(ID).append(":").append(id).append("\n");
        sb.append(INTRO).append(":").append(intro).append("\n");
        sb.append(LOGOURL).append(":").append(logoUrl).append("\n");
        sb.append(LOGOURLMODEL).append(":")
                .append(logoUrlModel != null ? logoUrlModel.toString() : "null").append("\n");
        return super.toString();
    }

    public static AppRecommend parse(JSONObject jsonObject) {
        AppRecommend appRecommend = new AppRecommend();

        appRecommend.setAppName(jsonObject.optString(AppRecommend.APPNAME));
        appRecommend.setAppStoreUrl(jsonObject.optString(AppRecommend.APPSTOREURL));
        appRecommend.setAndroidStoreUrl(jsonObject.optString(AppRecommend.ANDROIDSTOREURL));
        appRecommend.setWpStoreUrl(jsonObject.optString(AppRecommend.WPSTOREURL));
        appRecommend.setIosStoreUrl(jsonObject.optString(AppRecommend.IOSSTOREURL));
        appRecommend.setGmtCreate(jsonObject.optString(AppRecommend.GMTCREATE));
        appRecommend.setGmtModified(jsonObject.optString(AppRecommend.GMTMODIFIED));
        appRecommend.setId(jsonObject.optInt(AppRecommend.ID));
        appRecommend.setIntro(jsonObject.optString(AppRecommend.INTRO));
        appRecommend.setLogoUrl(jsonObject.optString(AppRecommend.LOGOURL));

        JSONObject jsonUrlModel = jsonObject.optJSONObject(AppRecommend.LOGOURLMODEL);
        LogoUrlModel logoUrlModel = new LogoUrlModel();
        if (jsonUrlModel != null) {
            logoUrlModel.path = jsonUrlModel.optString(LogoUrlModel.PATH);
            logoUrlModel.sum100x000 = jsonUrlModel.optString(LogoUrlModel.SUM100X000);
            logoUrlModel.url = jsonUrlModel.optString(LogoUrlModel.URL);
        }
        appRecommend.setLogoUrlModel(logoUrlModel);
        return appRecommend;
    }

}
